//
//  MainViewController.swift
//  SinaWeibo
//
//  Created by yimin on 16/1/11.
//  Copyright © 2016年 yimin. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print(tabBar.classForCoder)
        let mainTabBar=MainTabBar()
        setValue(mainTabBar, forKey: "tabBar")
        print(tabBar.classForCoder)
        
        
        addChildViewControllers()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    // MARK: 添加所有的子控制器
   private func addChildViewControllers(){
        tabBar.tintColor=UIColor.orangeColor()
        addChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileViewController(), title: "我", imageName: "tabbar_profile")
    }
    
    // MARK: 添加子控制器
   private func addChildViewController(vc:UIViewController,title:String, imageName:String){
        vc.title=title
        vc.tabBarItem.image=UIImage(named: imageName)
        addChildViewController(UINavigationController(rootViewController: vc))
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
